package com.ruoyi.wcf.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wcf.domain.WcfMobile;
import com.ruoyi.wcf.service.IWcfMobileService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 手机-品牌-系列-型号Controller
 * 
 * @author WZP
 * @date 2022-04-02
 */
@RestController
@RequestMapping("/wcf/WcfMobile")
public class WcfMobileController extends BaseController
{
    @Autowired
    private IWcfMobileService wcfMobileService;

    /**
     * 查询手机-品牌-系列-型号列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobile:list')")
    @GetMapping("/list")
    public TableDataInfo list(WcfMobile wcfMobile)
    {
        startPage();
        List<WcfMobile> list = wcfMobileService.selectWcfMobileList(wcfMobile);
        return getDataTable(list);
    }

    /**
     * 导出手机-品牌-系列-型号列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobile:export')")
    @Log(title = "手机-品牌-系列-型号", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WcfMobile wcfMobile)
    {
        List<WcfMobile> list = wcfMobileService.selectWcfMobileList(wcfMobile);
        ExcelUtil<WcfMobile> util = new ExcelUtil<WcfMobile>(WcfMobile.class);
        return util.exportExcel(list, "手机-品牌-系列-型号数据");
    }

    /**
     * 获取手机-品牌-系列-型号详细信息
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobile:query')")
    @GetMapping(value = "/{mobileId}")
    public AjaxResult getInfo(@PathVariable("mobileId") Long mobileId)
    {
        return AjaxResult.success(wcfMobileService.selectWcfMobileByMobileId(mobileId));
    }

    /**
     * 新增手机-品牌-系列-型号
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobile:add')")
    @Log(title = "手机-品牌-系列-型号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WcfMobile wcfMobile)
    {
        return toAjax(wcfMobileService.insertWcfMobile(wcfMobile));
    }

    /**
     * 修改手机-品牌-系列-型号
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobile:edit')")
    @Log(title = "手机-品牌-系列-型号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WcfMobile wcfMobile)
    {
        return toAjax(wcfMobileService.updateWcfMobile(wcfMobile));
    }

    /**
     * 删除手机-品牌-系列-型号
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobile:remove')")
    @Log(title = "手机-品牌-系列-型号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mobileIds}")
    public AjaxResult remove(@PathVariable Long[] mobileIds)
    {
        return toAjax(wcfMobileService.deleteWcfMobileByMobileIds(mobileIds));
    }
}
